package com.longsunhd.yum.buffalo.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.widget.TextView;

import java.util.logging.Handler;

import cn.addapp.pickers.picker.DatePicker;

/**
 * 作者：黄宣淇
 * 时间：2021/5/11 0011
 * 如何代码没有备注，一个月后，只有你和上帝知道--鲁迅
 */
public class DataPickerUtil {
    public static void showDataPicker(Activity context, TextView showTextView){
        final DatePicker picker = new DatePicker(context);
        picker.setTopPadding(15);
        picker.setRangeStart(2018, 8, 29);
        picker.setRangeEnd(2030, 1, 11);
        picker.setSelectedItem(2021, 5, 8);
        picker.setWeightEnable(true);
        picker.setLineColor(Color.BLACK);
        picker.setOnDatePickListener(new DatePicker.OnYearMonthDayPickListener() {
            @Override
            public void onDatePicked(String year, String month, String day) {
                showTextView.setText(year + "-" + month + "-" + day);

            }
        });
        picker.setOnWheelListener(new DatePicker.OnWheelListener() {
            @Override
            public void onYearWheeled(int index, String year) {
                picker.setTitleText(year + "-" + picker.getSelectedMonth() + "-" + picker.getSelectedDay());
            }

            @Override
            public void onMonthWheeled(int index, String month) {
                picker.setTitleText(picker.getSelectedYear() + "-" + month + "-" + picker.getSelectedDay());
            }

            @Override
            public void onDayWheeled(int index, String day) {
                picker.setTitleText(picker.getSelectedYear() + "-" + picker.getSelectedMonth() + "-" + day);
            }
        });
        picker.show();
    }
}
